from core.basePage import BasePage
from core.model import ElementModel
from pages.zentao.DashboardPage import DashboardPage


class LoginPage(BasePage):
    element_username_input = ElementModel(desc='登录-账号输入框', selector='//input[@name="account"]')
    element_password_input = ElementModel(desc='登录-密码输入框', selector='//input[@name="password"]')
    element_login_button = ElementModel(desc='登录-登录按钮', selector='//button[@id="submit"]')


    def flow_login_submit(self, host, username, password):
        self.go_to(host)
        self.input_text(self.element_username_input, username)
        self.input_text(self.element_password_input, password)
        self.click(self.element_login_button)

    def assert_login_is_success(self):
        self.wait_for_visible(DashboardPage.element_my_index_tag)

    def assert_login_fail_by_tips(self, tips):
        assert self.is_visible()==True